package com.example.csdn.mapper;

import com.example.csdn.DTO.AddCategoryDTO;
import com.example.csdn.DTO.UpdateCategoryDTO;
import com.example.csdn.pojo.Category;
import com.example.csdn.pojo.Result;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CategoryMapper {

    @Select("select * from category")
    List<Category> AllCategory();

    @Select("select * from category where id = #{id}")
    Category findById(Integer id);

    @Insert("insert into category(category_name,category_des,create_time)" +
            "values (#{categoryName},#{categoryDes},now())")
    void add(AddCategoryDTO addCategoryDTO);

    @Update("update category set category_name = #{categoryName},category_des = #{categoryDes} where id = #{id}")
    void update(Category category);

    @Delete("delete from category where id = #{id}")
    void delete(Integer id);
}
